#include "MatchCreature.h"
#include "Constraint.h"

namespace jcrada {

    MatchCreature::MatchCreature(int hidden_layers, int neurons_per_layer) :
    Creature(BODY_PARTS, CONSTRAINTS, hidden_layers, neurons_per_layer) {
        setName("MatchCreature");
    }

    MatchCreature::~MatchCreature() {
    }

    void MatchCreature::set(const btTransform& at) {
        getBodyPart(HEAD).setId(HEAD);
        getBodyPart(HEAD).setName("Head");
        getBodyPart(HEAD).setParentId(Creature::B_NONE);
        getBodyPart(HEAD).setShape(BodyPart::S_SPHERE);
        getBodyPart(HEAD).setSize(1.0, 1.0, 1.0);
        getBodyPart(HEAD).setMass(1.0);

        getBodyPart(STICK).setId(STICK);
        getBodyPart(STICK).setName("Stick");
        getBodyPart(STICK).setParentId(HEAD);
        getBodyPart(STICK).setShape(BodyPart::S_CAPSULE_X);
        getBodyPart(STICK).setSize(0.2, 2.0, 0.2);
        
        getBodyPart(STICK).setMass(1.5);

        getConstraint(NECK).setId(NECK);
        getConstraint(NECK).setType(Constraint::CT_CONE_TWIST);
        getConstraint(NECK).setName("Neck");
        getConstraint(NECK).setIdBodyA(getBodyPart(HEAD).getId());
        getConstraint(NECK).setIdBodyB(getBodyPart(STICK).getId());
        getConstraint(NECK).setConnectionA(Constraint::SPHERE_BOTTOM);
        getConstraint(NECK).setConnectionB(Constraint::CYLINDER_R3_FRONT);
        getConstraint(NECK).setConeSwingX(0);
        getConstraint(NECK).setConeTwistY(M_PI);
        getConstraint(NECK).setConeSwingZ(0);

        Creature::set(at);
    }
}
